<?php
require_once('lib/menu.php');
require_once('lib/content.php');

// admin/modo
$is_admin = $_SESSION['status_code'] == 'ADMIN';
?>
<script src="pages_admin/redaction/_redaction.js" type="text/javascript"></script>
<div id="contenus_gestion">
<h3>Gestion des contenus</h3>
<?php
$contents = content_get_list();
if ($row = mysql_fetch_assoc($contents)) {
	?>
	<table class="dataTable">
		<thead>
		<tr>
			<th>&nbsp;</th>
			<th>Identifiant</th>
			<th>Titre</th>
			<th>Menu associé</th>
			<th>Action</th>
		</tr>
		</thead>
		<tbody>
	<?php
	do {
		$menu = menu_get_by_id($row['idMenu']);
		$lock = $row['locked'] ? icon_tag('lock') : '&nbsp;';
		echo '
		<tr>
			<td>'.$lock.'</td>
			<td>'.$row['id'].'</td>
			<td>'.$row['title'].'</td>
			<td>'.$menu['name'].'</td>
			<td>
				<a href="javascript:void(0);" class="js-ask-details" id="content-'.$row['id'].'" title="Voir le texte">
					<img src="images/icons/magnifier.png" alt="Texte" />
				</a>';

				if($is_admin) {
					echo'
					<a href="?p=redaction&amp;r=contenus_ajouter&amp;id='.$row['id'].'" title="Modifier ce contenu">
						<img src="images/icons/pencil.png" alt="edit" />
					</a>';

					if(!$row['locked'])
						echo '
						<span>
							<a href="javascript:void(0);" class="js-ask-validation" title="Supprimer ce contenu">
								<img src="images/icons/delete.png" alt="Supprimer" />
							</a>
							<div class="hidden decalhaut">
								Supprimer ?<br />
								<a href="javascript:void(0);" class="js-del-content b-oui" id="delcontent-'.$row['id'].'"></a>
								<a href="javascript:void(0);" class="js-hide b-non"></a>
							</div>
						</span>';
				}

				echo '
			</td>
		</tr>';
	} while ($row = mysql_fetch_assoc($contents));
	?>
		</tbody>
	</table>
	<div id="details" title="Details du contenu"></div>
<?php
}
else {
	?>
	<p class="info">
		Il n'y a aucun contenu pour le moment
	</p>
	<?php
} ?>
</div>
